package com.intexh.quickandroid.module.chat.util;

import android.content.Context;

import com.intexh.quickandroid.module.chat.bean.ChatMessage;
import com.intexh.quickandroid.module.chat.bean.ChatSession;
import com.intexh.quickandroid.module.chat.sprinkles.Migration;
import com.intexh.quickandroid.module.chat.sprinkles.Sprinkles;

/**
 * @author Jecelyin <jecelyin@gmail.com>
 * @since 2014.02.17
 */
public class DbHelper {
    public static void init(Context context) {
        createAllTable(context);
    }

    @SuppressWarnings("rawtypes")
    static Class[] tables = {ChatMessage.class, ChatSession.class};

    @SuppressWarnings("unchecked")
    private static void createAllTable(Context context) {
        Sprinkles sprinkles = Sprinkles.init(context, "chat_1.db", 1);
        Migration migration=new Migration();
        for (Class table : tables) {
            migration.updateTable(table);
        }
        sprinkles.execMigration(migration);
    }
    public static void deleteFromAllTable() {
        DBUtil.deleteAlltableSync(tables);
    }



}
